import * as njk from 'nunjucks';
import { ServicesGenerator, TypingGenerator } from './core';
import * as fs from 'fs';
import { log } from './utils';

const typingGenerator = new TypingGenerator('./response.json');
const servicesGenerator = new ServicesGenerator('./response.json');

// 清空api文件夹
const files = fs.readdirSync('./api');
files.forEach((file) => {
  if (file !== '.gitkeep') {
    fs.unlinkSync(`./api/${file}`);
  }
});

log('api文件夹已清空，开始生成');

typingGenerator.start();
servicesGenerator.start();

// const str = njk.renderString(typeTpl, {
//   name: 'AlertDetailModel',
//   properties: [
//     {
//       name: 'actualValue',
//       description: '浓度',
//       example: 12.0,
//       type: 'number',
//     },
//     {
//       name: 'address',
//       type: 'string',
//       example: '白堤路',
//       description: '地址',
//     },
//   ],
// });
